﻿using System;
using System.Collections.Generic;
using System.Text;

namespace XProject.Commons.TypeUtil.ConverterTypes
{
    public class DecimalType : IConvertibility
    {

        #region IConvertibility 成员

        public object[] GetRegisterKeys()
        {
            return new object[]{ typeof(decimal) };
        }

        public object GetValue(string strValue)
        {
            if (string.IsNullOrEmpty(strValue)) return Decimal.Zero;
            return Convert.ToDecimal(strValue);
        }

        public string GetValueStr(object value)
        {
            if (value == null || !(value is decimal))
            {
                return "0";
            }
            return ((decimal)value).ToString("#.######");
        }

        #endregion
    }
}
